%
c=[13 9 10 11 12 8];
A=[0.4 1.1 1 0 0 0;0 0 0 0.5 1.2 1.3];
b=[800;900];
Aeq=[1 0 0 1 0 0;
    0 1 0 0 1 0;
    0 0 1 0 0 1];
beq=[400 600 500];
vlb=zeros(6,1);
vub=[];
[x,fval]=linprog(c,A,b,Aeq,beq,vlb,vub);
%%
f=[-0.4 -0.28 -0.32 -0.72 -0.64 -0.6];
A1=[0.01 0.01 0.01 0.03 0.03 0.03;
    0.02 0 0 0.05 0 0;
    0 0.02 0 0 0.05 0;
    0 0 0.03 0 0 0.08];
b1=[850;700;100;900];
Aeq2=[];beq2=[];
vlb2=[0;0;0;0;0;0];vub2=[];
[x,fval]=linprog(f,A1,b1,Aeq2,beq2,vlb2,vub2);
%%
clc,clear
f=[-5 -8];
A=[1 1;5 9];
b=[6 45];
lb=zeros(2,1);
intcon=[1 2];
[x,fval]=intlinprog(f,intcon,A,b,[],[],lb,[]);
x,fval=-fval
%%
clc,clear
f=[-5 -8];
A=[1 1;5 9];
b=[6 45];
ul=zeros(2,1);
intcon=[1 2];
[x,fval]=intlinprog(f,intcon,A,b,[],[],ul,[]);
x,fval=-fval
%%
clc,clear
f=[-6 -2 -3 -5];
A=[-3 5 -1 -6;
    2 1 1 -1;
    1 2 4 5];
b=[-4 3 10];
intcon=[1,2,3,4];
lb=zeros(4,1);
ub=ones(4,1);
[x,fval]=intlinprog(f,intcon,A,b,[],[],lb,ub);
x,fval=-fval
%%
clc, clear
prob = optimproblem;  
x = optimvar('x',6,'Type','integer','LowerBound',0);  %创建整数变量
prob.Objective = sum(x);
con = optimconstr(6);     %创建一个n维优化问题的约束条件对象
a = [35,40,50,45,55,30];
con(1) = x(1)+x(6)>=35;
for i =1 :5
    con(i+1) = x(i)+x(i+1)>=a(i+1);
end
prob.Constraints.con = con;
[sol, fval, flag] = solve(prob), sol.x